//
//  XJMyOrderSectionHeaerView.m
//  XinJiangMall
//
//  Created by RaoBo on 2018/5/26.
//  Copyright © 2018年 Tzyang. All rights reserved.
//  订单区头

#import "XJMyOrderSectionHeaerView.h"
@interface XJMyOrderSectionHeaerView()
@property(nonatomic, strong) UIView *bgView; // 习惯

@property(nonatomic, strong) UIView *leftView; // 左边view
@property(nonatomic, strong) UIImageView *iconIv;
@property(nonatomic, strong) UILabel *shopNameLabel;

@property(nonatomic, strong) UILabel *rightLabel; // 右边Label


@end

@implementation XJMyOrderSectionHeaerView

#pragma mark - 一 初始化
- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
   self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self) {
        [self setupView];
    }
    
    return self;
}

- (void)setupView {
    [self.contentView addSubview:self.bgView];
    
    
    [self.bgView addSubview:self.leftView];
    [self.leftView addSubview:self.iconIv];
    [self.leftView addSubview:self.shopNameLabel];

    
    [self.bgView addSubview:self.rightLabel];
}

#pragma mark - 一 初始化

#pragma mark - 二 lazy
- (UIView *)bgView {
    if (!_bgView) {
        _bgView = [UIView new];
        _bgView.backgroundColor = [UIColor whiteColor];
    }
    return _bgView;
}

- (UIView *)leftView {
    if (!_leftView) {
        _leftView = [[UIView alloc] init];
    }
    return _leftView;
}
- (UIImageView *)iconIv {
    if (!_iconIv) {
        _iconIv = [[UIImageView alloc] init];
        _iconIv.image = [UIImage imageNamed:@"order_shop"];
        _iconIv.layer.cornerRadius = _iconIv.frame.size.width / 2;
        _iconIv.layer.masksToBounds = YES;
    }
    return _iconIv;
}

- (UILabel *)shopNameLabel {
    if (!_shopNameLabel) {
        _shopNameLabel = [[UILabel alloc] init];
        _shopNameLabel.text = @"幸福小铺";
    }
    return _shopNameLabel;
}



- (UILabel *)rightLabel {
    if (!_rightLabel) {
        _rightLabel = [[UILabel alloc] init];
        _rightLabel.text  =  @"单付款";
        _rightLabel.textColor = [UIColor redColor];
    }
    return _rightLabel;
}
#pragma mark - 三 layout

- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self.contentView);
    }];
    
   
    [self.leftView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgView.mas_left).offset(10);
        make.centerY.equalTo(self.bgView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(200, 40));
    }];
    [self.iconIv mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftView);
        make.centerY.equalTo(self.leftView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(30, 30));
    }];
    [self.shopNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.iconIv.mas_right).offset(10);
        make.centerY.equalTo(self.leftView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(150, 30));
    }];
    
    
    
    [self.rightLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bgView.mas_right).offset(-10);
        make.centerY.equalTo(self.bgView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(100, 30));
    }];
}


- (void)configureMyOrderSectionHeaderViewShopName:(NSString *)name rightTitle:(NSString *)title {
    
    self.shopNameLabel.text = [NSString stringWithFormat:@"%@ >",name];
    
    self.rightLabel.text = title;
}
@end
